package cn.iocoder.yudao.module.scrm.dal.mysql.schedules;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.scrm.controller.admin.schedules.vo.SchedulesPageReqVO;
import cn.iocoder.yudao.module.scrm.dal.dataobject.customer.CustomerDO;
import cn.iocoder.yudao.module.scrm.dal.dataobject.schedules.SchedulesDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * 排期 Mapper
 *
 * @author admin
 */
@Mapper
public interface SchedulesMapper extends BaseMapperX<SchedulesDO> {

    default PageResult<SchedulesDO> selectPage(SchedulesPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SchedulesDO>()
                .likeIfPresent(SchedulesDO::getName, reqVO.getName())
                .eqIfPresent(SchedulesDO::getProductId, reqVO.getProductId())
                .betweenIfPresent(SchedulesDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(SchedulesDO::getEndTime, reqVO.getEndTime())
                .eqIfPresent(SchedulesDO::getAddress, reqVO.getAddress())
                .eqIfPresent(SchedulesDO::getSeatCount, reqVO.getSeatCount())
                .eqIfPresent(SchedulesDO::getRemark, reqVO.getRemark())
                .eqIfPresent(SchedulesDO::getCreator,reqVO.getCreator())
                .betweenIfPresent(SchedulesDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(SchedulesDO::getStatus,reqVO.getStatus())
                .orderByDesc(SchedulesDO::getId));
    }

    IPage<CustomerDO> queryScheduleCustomer(IPage<CustomerDO> page, @Param("id") Long id, @Param("creator") String creator);

}